﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebClient.aspx.cs" Inherits="Skynet.WebSite.Demos.WebClient" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript">
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>                 
                 <asp:ServiceReference Path="http://localhost:10001/SkynetLibraryWeb.svc" />
            </Services>           
    </asp:ScriptManager>
     <script type="text/javascript">
         function generateGuid() {
             var result, i, j;
             result = '';
             for (j = 0; j < 32; j++) {
                 if (j == 8 || j == 12 || j == 16 || j == 20)
                     result = result + '-';
                 i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
                 result = result + i;
             }
             return result
         }
         function callservice() {
             var application = "A3FAB158-90E6-44C9-B716-241F97E82ECF";
             var id = generateGuid();
             var d=new Date();
             var t = d.toGMTString();
             ISkynetLibraryWeb.RegisterMethodInterceptor(id, 'Skydotnet', application, operation, "WebSite", "JsonClient", "TestMethod", t, onsuccess);
         }
         var operation = generateGuid();
         function dowork() {
             operation = generateGuid();
             callservice();
             ISkynetLibraryWeb.GetSystemDate(endGetSystemDate);                      
         }
         function getCostAverage() {
             ISkynetLibraryWeb.GetOperationAverage('Skydotnet', "WebSite", "JsonClient", "TestMethod", EndgetCostAverage);
         }
         function EndgetCostAverage(result)
         {
            alert(result);
         }
         function endGetSystemDate(result) {
             callservice();    
         }
         function onsuccess(result) {
             alert('success');
         }
         function onfailure(result) {
             alert(result);
         }
    </script>
    <div>
        <input id="Button1" type="button" value="button" onclick="return dowork();" />
        <input id="Button2" type="button" value="GetCostAverage" onclick="return getCostAverage();" />
        
    </div>
    </form>
</body>
</html>
